package org.dreamwork.jasmine2.parser;

public class TagUtil {
    private static final String[] EMPTY_TAG = {
         // HTML Elements
        "meta", "br", "hr", "link", "img", "input",
    };

    private static final String[] BLOCK_TAG = {
        "p", "div", "table", "ul", "ol", "iframe", "pre", "hr", "form",
        "h1", "h2", "h3", "h4", "h5", "h6",
    };

    private static final String[] OPTIONAL_CLOSE_TAG = {
        "p", "li", "option",
    };

    private static final String[] MUST_CLOSE_TAG = {
        "textarea", "iframe", "title", "script"
    };

    public static boolean isEmptyTag (String name) {
        return isInArray (EMPTY_TAG, name);
    }

    public static boolean isBlockTag (String name) {
        return isInArray (BLOCK_TAG, name);
    }

    public static boolean isOptionalTag (String name) {
        return isInArray (OPTIONAL_CLOSE_TAG, name);
    }

    public static boolean isMustCloseTag (String name) {
        return isInArray (MUST_CLOSE_TAG, name);
    }

    private static boolean isInArray (String[] array, String str) {
        for (int i = 0; i < array.length; i ++) if (str.equalsIgnoreCase (array [i])) return true;
        return false;
    }
}